package cn.xz.tipsum.dialog

import android.content.Intent
import android.view.Gravity
import android.widget.TextView
import cn.xz.tipsum.R
import cn.xz.tipsum.base.BaseDialogRxFragment

/**
 * 选择权限提示弹窗
 * */
class SelectDialog: BaseDialogRxFragment() {

    private var cvYes: TextView? = null
    private var cvNo: TextView? = null

    companion object {
        fun newInstance(): SelectDialog {
            return SelectDialog()
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.dialog_select
    }

    override fun configDialog() {
        this.setDialogSize(gravity = Gravity.CENTER,width = 500)
    }

    override fun initViews() {

        dialog?.let {
            cvYes = it.findViewById(R.id.cv_yes)
            cvNo = it.findViewById(R.id.cv_no)
        }
        //点击事件
        initEvent()
    }


    private fun initEvent(){
        cvYes?.setOnClickListener {
            val intent = Intent()
            intent.action = "android.settings.APP_NOTIFICATION_SETTINGS";
            intent.putExtra("app_package", "com.tencent.mm");
            // for Android 8 and above
            intent.putExtra("android.provider.extra.APP_PACKAGE", "com.tencent.mm");
            this.startActivity(intent);
            dismiss()
        }
        cvNo?.setOnClickListener {
            val intent = Intent()
            intent.action = "android.settings.APP_NOTIFICATION_SETTINGS";
            intent.putExtra("app_package", "com.eg.android.AlipayGphone");
            // for Android 8 and above
            intent.putExtra("android.provider.extra.APP_PACKAGE", "com.eg.android.AlipayGphone");
            this.startActivity(intent);
            dismiss()
        }
    }

}